package com.scut.campus.controller;


import com.scut.campus.response.Result;
import com.scut.campus.utils.AliOSSUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;

@RestController
@RequestMapping("/upload")
@Tag(name = "上传图片接口")
@Slf4j
public class UploadController {

    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping
    @Operation(summary = "上传图片")
    public Result upload(MultipartFile image) throws IOException {
        String url=aliOSSUtils.upload(image);
        return Result.success(url);
    }
}
